package cn.backpackerxl.server.impl;
import cn.backpackerxl.model.Student;
import cn.backpackerxl.server.StudentService;
import cn.backpackerxl.repo.StudentDao;
import cn.backpackerxl.easyJDBC.main.EasyJDBCRepository;

import java.util.List;
/**
 * @Author: backpackerxl
 * CreateTime: 2022/11/24
 * FileName: StudentServiceImpl
 **/
public class StudentServiceImpl implements StudentService {
	private final StudentDao studentdao = (StudentDao) new EasyJDBCRepository(StudentDao.class).init();

	@Override
	public int add(Student student) {
		return studentdao.save(student);
	}

	@Override
	public int edit(Student student) {
		return studentdao.update(student);
	}

	@Override
	public int delete(Long id) {
		return studentdao.remove(id);
	}

	@Override
	public Student selectById(Long id) {
		return studentdao.findById(id);
	}

	@Override
	public List<Student> selectAll() {
		return studentdao.findAll();
	}

}